package jay.home.bet.web.struts;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import jay.home.bet.domain.Event;
import jay.home.bet.misc.Util;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class UpdateRuqiushuAction extends BaseAction {
	
	@Override
	public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception 
	{
		request.getParameterMap();
		String id = request.getParameter("id");
		Event event = getOddsService().getEventByComp(id);
		
		event.getRuqiushu().setS01(Util.toDouble(request.getParameter("ruqiushu.s01")));
		event.getRuqiushu().setS23(Util.toDouble(request.getParameter("ruqiushu.s23")));
		event.getRuqiushu().setS46(Util.toDouble(request.getParameter("ruqiushu.s46")));
		event.getRuqiushu().setSup7(Util.toDouble(request.getParameter("ruqiushu.sup7")));
		
		event.getDanshuang().setOdd(Util.toDouble(request.getParameter("danshuang.odd")));
		event.getDanshuang().setEven(Util.toDouble(request.getParameter("danshuang.even")));
		
		event.getDuyingHalf().setWin(Util.toDouble(request.getParameter("duyingHalf.win")));
		event.getDuyingHalf().setLose(Util.toDouble(request.getParameter("duyingHalf.lose")));
		event.getDuyingHalf().setDraw(Util.toDouble(request.getParameter("duyingHalf.draw")));
		
		
		getOddsService().updateEventsByComp(event);
		Map map = getOddsService().getCounter(event.getId());
		
		request.setAttribute("event", event);
		request.setAttribute("map", map);
		return mapping.findForward("SUCCESS");
	}
}
